<?php
/**
 * @file WCParserBehaviorOVER.php
 * @author Alejandro Dario Simi
 * @date $Date: 2012-12-28 01:08:14 +0000 (Fri, 28 Dec 2012) $
 *
 * $Id: WCParserBehaviorOVER.php 47 2012-12-28 01:08:14Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0-BETA2/includes/parser/WCParserBehaviorOVER.php $
 */

require_once dirname(__FILE__)."/WCParserBehavior.php";

$WCParserBehaviorMatrix["OVER"]	= "WCParserBehaviorOVER";

class WCParserBehaviorOVER extends WCParserBehavior {
	public function check() {
		if($this->_node) {
			$this->_ok = true;
			$this->_errorMsg = "Ok";
		} else {
			$this->_errorMsg = "OVER node is not set";
			$this->_ok = false;
		}

		return $this->isOk();
	}
	public function get() {
		$out = false;

		if($this->isOk()) {
			$params = $this->_node->params();
			$over = array();

			if(isset($params["list"])) {
				$overArray = $params["list"];
				if($this->_parser->has($overArray)) {
					$over = $this->_parser->$overArray;
				} else {
					/// @todo check error
				}

				$currVariables = $this->_parser->variables();

				$simpleWay	= isset($params["key"]) ? $params["key"] : false;
				$out		= "";
				foreach($over as $key => $extraValues) {
					if($simpleWay) {
						$this->_parser->assign($simpleWay, $extraValues);
					} else {
						$this->_parser->massiveAssign($extraValues);
					}
					$out .= $this->_node->parseChildren();

					$this->_parser->massiveAssign($currVariables, true);
				}
			} else {
				/// @todo check error
			}
		}

		return $out;
	}
}

?>